import { ObjCreate } from "../../common/ObjCreate";
import { TitleItem } from "../../common/item/TitleItem";
import { Language } from "../../../../../extend/language/Language";
import { ObjTeamCreate } from "../../common/ObjTeamCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { TilePanel } from "../../equipment/TilePanel";
import { ArenaCrossGroupTopListCellRenderer } from "../cellRenderer/ArenaCrossGroupTopListCellRenderer";
import { ArenaCrossGetListData } from "../arenaCrossData/ArenaCrossGetListData";
import { Cache } from "../../../cache/Cache";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Global } from "../../../../../com/gengine/global/Global";
import { SArenaCrossToplists } from "../../../../../Message/Public/SArenaCrossToplists";
import { DataProvider } from "../../../../../fl/data/DataProvider";
type int = number;
//class ArenaCrossGroupMatchTopListPanel
    
    export  class ArenaCrossGroupMatchTopListPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createSpBannerAndBg(0, 0, 544, 483, "", this);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(44241), 50));
            loc1.push(new TitleItem(Language.getString(44242), 180));
            loc1.push(new TitleItem(Language.getString(44206), 60));
            loc1.push(new TitleItem(Language.getString(44246), 50));
            loc1.push(new TitleItem(Language.getString(44247), 50));
            loc1.push(new TitleItem(Language.getString(44248), 60));
            loc1.push(new TitleItem(Language.getString(44249), 75));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 2, 8, -1, -1, this);
            this._tfNoResult = ObjCreate.createTextField(Language.getString(44251), 235, 243, 200, 20, this, GlobalStyle.textFormat6);
            this._tfNoResult.visible = false;
            this._topListPanel = new TilePanel();
            this._topListPanel.setSize(540, 450);
            this._topListPanel.rowHeight = 45;
            this._topListPanel.columnWidth = 540;
            this._topListPanel.setStyle("cellRenderer", ArenaCrossGroupTopListCellRenderer);
            this._topListPanel.x = 0;
            this._topListPanel.y = 30;
            this.addChild(this._topListPanel);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this.getData();
            return;
        }

        /* internal  */getData(): void
        {
            var loc1=this._groupId == 0;
            var loc2=new ArenaCrossGetListData(Cache.instance.arenaCross.arenaCrossInfo.process, 1, 50, loc1, false, this._groupId);
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetArenaLists, loc2));
            return;
        }

        public get groupId(): int
        {
            return this._groupId;
        }

        public set groupId(arg1: int)
        {
            this._groupId = arg1;
            if (Global.stage.contains(this)) 
            {
                this.getData();
            }
            return;
        }

        public updateTopList(arg1: SArenaCrossToplists): void
        {
            this._topListPanel.dataProvider = new DataProvider(arg1.toplists);
            var loc1=this._topListPanel.dataProvider.length > 0;
            this._topListPanel.visible = loc1;
            this._tfNoResult.visible = !loc1;
            return;
        }

        /* internal */ /* var */_groupId: int=0;

        /* internal */ /* var */_tfNoResult: Object /* flash.text.TextField */;

        /* internal */ /* var */_topListPanel: TilePanel;
    }
